package com.lancoo.znbkxx.teacher.diagnosis

import android.graphics.Color
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.lancoo.znbkxx.teacher.R
import com.lancoo.znbkxx.teacher.model.data.TopicZsd
import kotlinx.android.synthetic.main.item_unstudy_vocab.view.*
import java.math.BigDecimal

/**
 *@author Admin
 *@date 2021/1/4
 *
 */
class UnStudyTopicListAdapter(val type: Int, data: List<TopicZsd>) :
        BaseQuickAdapter<TopicZsd, BaseViewHolder>(data) {
    init {
        mLayoutResId = R.layout.item_unstudy_vocab
    }

    override fun convert(helper: BaseViewHolder, item: TopicZsd?) {
        with(helper.itemView) {
            tv_vocab.text = item?.ZsdString
            tv_percent.apply {
                setTextColor(Color.parseColor(when (type) {
                    0 -> "#00afff"
                    1 -> "#22d7bb"
                    else -> "#999999"
                }))
                text = BigDecimal(item?.TestRate).setScale(2, BigDecimal.ROUND_HALF_UP)
                    .toPlainString()
            }
        }
    }
}